﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NyxBot
{
    public partial class frmTemplate : Form
    {
        // Columns
        private ColumnHeader hIcon;
        private ColumnHeader hName;
        private ColumnHeader hClan;
        private ColumnHeader hPing;

        public frmTemplate()
        {
            InitializeComponent();
        }

        private void frmTemplate_Load(object sender, EventArgs e)
        {
            // This class is a template for everything like channel windows,
            // friends list, clans list, etc

            // Setup the listview
            int width = Convert.ToInt32(lvMain.Font.SizeInPoints);
            hIcon = lvMain.Columns.Add("Icon", 32, HorizontalAlignment.Center);
            hName = lvMain.Columns.Add("Name", 30 * width, HorizontalAlignment.Center);
            hClan = lvMain.Columns.Add("Clan", 4 * width, HorizontalAlignment.Center);
            hPing = lvMain.Columns.Add("Ping", 5 * width, HorizontalAlignment.Center);

            AddText("Orange", "NyxBot");
        }

        public void ListViewAdd(object image, string name, string clan, int ping)
        {
            // Adds an item into the listview
        }

        public void ListViewRemove(string name)
        {
            // Removes an item from the listview
        }

        public void ListViewClear()
        {
            // Clears the listview
            lvMain.Items.Clear();
        }

        public void AddRTBItem(Color color, string text)
        {
            rtbChat.SelectionStart = rtbChat.Text.Length;
            rtbChat.SelectionLength = 0;
            rtbChat.SelectionColor = color;
            rtbChat.SelectedText = text;
            rtbChat.SelectionStart = rtbChat.Text.Length;
            rtbChat.SelectionLength = 0;
        }

        public void AddText(params string[] items)
        {
            string timestamp = System.DateTime.Now.TimeOfDay.ToString();

            AddRTBItem(Color.White, "[" + timestamp + "] ");
            for (int i = 0; i < items.Length; i += 2)
            {
                string color = items[i];
                string text = items[i + 1];

                AddRTBItem(Color.FromName(color), text);
            }

            AddRTBItem(Color.White, "\r\n");
            rtbChat.ScrollToCaret();
        }

    }
}
